package com.liveinstars.gateway.application;

import com.liveinstars.gateway.application.filter.factory.AesAuthGatewayFilterFactory;
import com.liveinstars.gateway.application.filter.factory.JwtAuthGatewayFilterFactory;
import com.liveinstars.gateway.application.filter.factory.RateLimitByIPGatewayFilterFactory;
import com.liveinstars.gateway.application.filter.factory.RsaAuthGatewayFilterFactory;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.codec.ServerCodecConfigurer;

@SpringBootApplication(scanBasePackages = {"com.liveinstars.gateway.*","com.liveinstars.api","com.onepiece.cache"})
@EnableEurekaClient
@MapperScan("com.liveinstars.gateway.**.mapper")
@EnableFeignClients(basePackages = "com.liveinstars.api")
@Configuration
public class GateWayApplication {

    @Bean("RateLimitByIP")
    public RateLimitByIPGatewayFilterFactory rateLimitByIPGatewayFilterFactory() {
        return new RateLimitByIPGatewayFilterFactory();
    }



    @Bean("AesAuth")
    public AesAuthGatewayFilterFactory aesAuthGatewayFilterFactory() {
        return new AesAuthGatewayFilterFactory();
    }

    @Bean("RsaAuth")
    public RsaAuthGatewayFilterFactory rsaAuthGatewayFilterFactory() {
        return new RsaAuthGatewayFilterFactory();
    }


    @Bean("JwtAuth")
    public JwtAuthGatewayFilterFactory jwtAuthGatewayFilterFactory() {
        return new JwtAuthGatewayFilterFactory();
    }

    @Bean
    public ServerCodecConfigurer serverCodecConfigurer() {
        return ServerCodecConfigurer.create();
    }

    public static void main(String[] args) {
        SpringApplication.run(GateWayApplication.class, args);
    }
}